import random
print("猜一个数字，1~50之间的数字")
figure = random.randint(1,50)
for fly in range(1,4):
    munber = input("请输入数字：")
    if munber.isdigit() is False:
        print("请输入阿拉伯数字：")
    elif int(munber) < 0 or int(munber) > 50:
        print("请输入1~50之间的数字")
    elif figure == int(munber):
        print("恭喜你用了%d次猜对了" % fly)
        break
    elif figure > int(munber):
        print("你猜小了")
    else:
        print("你猜大了")
    if fly == 3:
        print("%d次机会用尽，答案为%d" % (fly,figure))